package com.lottery.module.dao;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.lottery.entity.LotterySaleLog;

@Repository
public class LotterySaleLogDao {

  @Autowired
  private JdbcTemplate jdbcTemplate;

  public void buy(LotterySaleLog lotterySaleLog) {
    StringBuffer sb = new StringBuffer();
    sb.append("insert into lottery_sale_log ");
    sb.append(" (sale_log_no,lottery_info_id,sale_money,sale_info,sale_place,create_time)");
    sb.append("values (?,?,?,?,?,?)");
    
    List<Object> params = new ArrayList<>();
    params.add(lotterySaleLog.getSaleLogNo());
    params.add(lotterySaleLog.getLotteryInfoId());
    params.add(lotterySaleLog.getSaleMoney());
    params.add(lotterySaleLog.getSaleInfo());
    params.add(lotterySaleLog.getSalePlace());
    params.add(new Date());
    
    jdbcTemplate.update(sb.toString(), params.toArray());
  }

}
